﻿using System.Collections.Generic;
using CooliteExample.Model;

namespace CooliteExamples.Code.DTO
{
    public class Book
    {
        public int BookId { get; set; }
        public string Title { get; set; }
        public string ISBN { get; set; }    
        public Category Category { get; set; }

        public int CategoryId
        {
            get
            {
                return Category.CategoryId;
            }
        }

        public string CategoryName
        {
            get
            {
                return Category.Name;
            }
        }

        public List<Author> Authors { get; set; }

        public Book()
        {
            Authors = new List<Author>();
            Category = new Category(0);
        }

        internal Book(mBook book)
        {
            Title = book.Title;
            ISBN = book.ISBN;

            if (book.CategoryReference.IsLoaded)
                Category = new Category(book.Category);
        }
    }
}
